package service

import (
	"context"
	"geek-homework/week04/internal/biz"
)

type UserService struct {
	uc *biz.UserUseCase
}

func NewUserService(uc *biz.UserUseCase) *UserService {
	return &UserService{uc: uc}
}

type GetUserResponse struct {
	Id   int64  `json:"id"`
	Name string `json:"name"`
}

func (s *UserService) GetUser(ctx context.Context, id int) (*GetUserResponse, error) {
	u, err := s.uc.Get(ctx, int64(id))
	if err != nil {
		return nil, err
	}

	return &GetUserResponse{Id: u.Id, Name: u.Name}, err
}
